package com.app;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.EditText;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.inputmethod.InputMethodManager;

public class GraphEdit extends EditText implements OnTouchListener {

	public GraphEdit(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init(context);
	}
	public GraphEdit(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context);
	}
	public GraphEdit(Context context) {
		super(context);
		init(context);
	}
	
	private void init(Context context){
	this.setOnTouchListener(this);
	this.setMaxLines(1);
	}
	
	@Override
	public boolean onTouch(View arg0, MotionEvent arg1) {
		super.onTouchEvent(arg1);
		this.setSelection(this.getText().length());
		//close standart keyboard
		InputMethodManager imm = (InputMethodManager) arg0.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.hideSoftInputFromWindow(arg0.getWindowToken(), 0);	
		return true;
	}
	public void setCursotPosition(){
		this.setSelection(this.getText().length());
	}

	
}
